package com.Web.cookie;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "CookieServletdemo2", value = "/CookieServletdemo2")
public class CookieServletdemo2 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
this.doPost(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//        3.获取Cookie
        Cookie[]  cookies= request.getCookies();
        if (cookies != null) {//cookies.nn可以快速生成判断不等式
            for (Cookie cookie1 : cookies) {
                System.out.println(cookie1.getName()+":"+cookie1.getValue());//name:jack
            }
        }
    }
}
